const mongoose = require('mongoose');

const userSchema = new mongoose.Schema({
  openid: {
    type: String,
    required: true,
  },
  zflistId: [{
    type: mongoose.Schema.Types.ObjectId,
    ref: 'ZF', // 这里假设你有名为 'ZFList' 的关联模型
  }],
  avatar: String,
  intr: String,
  staus: String,
  name: String,
  create_date: {
    type: Date,
    default: Date.now, // 设置默认值为当前日期时间
  },
  update_date: {
    type: Date,
    default: Date.now, // 设置默认值为当前日期时间
  },
}, {
  toJSON: {
    virtuals: true,
    transform: (doc, ret) => {
      ret.id = ret._id.toString();
      delete ret._id;
    },
  },
  versionKey: false,
});

const User = mongoose.model('User', userSchema);

module.exports = User;
